package com.edu.service.impl;

import com.edu.bean.User;
import com.edu.dao.UserDao;
import com.edu.dao.impl.UserDaoImpl;
import com.edu.service.UserService;

/**
 * @Author:qiufeng
 * @Date: 2024/9/14 15:25
 * @Description:
 */


public class UserServiceImpl implements UserService {
    UserDao ud=new UserDaoImpl();
    @Override
    public int registerService(User user) {
       int num= ud.rigister(user);
       return num;

    }

    @Override
    public User loginService(User user) {
        int result=ud.loginByUserName(user.getUsername());
        if (result==-1){
            System.out.println("用户不存在");
            return null;
        }else{
            User rUser=ud.loginByUserNameAndUserPass(user.getUsername(), user.getUserpass());
            if (rUser.getUserId()==-1){
                System.out.println("密码错误");

            }
            return rUser;
        }
    }
}
